<?php
/**

 */
class Form_MessageForm extends App_Form
{
    public function __construct($options = null)
    {
        parent::__construct($options);

		$locale = Zend_Registry::get('Zend_Locale');
		$locale_countries = ($locale->getTranslationList('Territory', 'en_US', 2));
		asort($locale_countries, SORT_LOCALE_STRING);
    	$countryList=array();
		$countrylist['']="All Countries";
		foreach($locale_countries as $k=>$v)
		{
			//$countrylist[$v['code']]=$v['value'];
			$countrylist[$k]=$v;
		}
        
        // change the class on the outer <dl> tag
        $this->getDecorator('HtmlTag')->setOption('class', 'form');

        $this->setName('messageForm');

        $model_service = new Model_Service();
    	$all_services = $model_service->getAllService();
                
        $departments=array();
        $departments[0]="For all service";
        foreach($all_services as $key =>$item){
        	$departments[ $item['dpt_id'] ] = $item['dpt_name'];
        }
		$dpt=new Zend_Form_Element_Select('dpt_id');
		$dpt->addMultiOptions($departments)
				->setAttrib('class','field text full')				
				->setAttrib('css','width:100px');				
				//->addDecorators(array( array( array("wrapper"=>'HtmlTag'), array('tag' => 'div','class' =>'left-column'))))
				//->setLabel('For service')
				//->getDecorator('Label')->setOptions(array('class'=>'desc'));

		
		$iconlist=array();
		$iconlist[0]='No Icon';
		$iconlist[1]='<img src="/images/yesup_bar/20x20_icon_1.png">';
		$iconlist[2]='<img src="/images/yesup_bar/20x20_icon_1.png">';
		$iconlist[3]='<img src="/images/yesup_bar/20x20_icon_1.png">';
		$iconlist[4]='<img src="/images/yesup_bar/20x20_icon_1.png">';
		$iconlist[5]='<img src="/images/yesup_bar/20x20_icon_1.png">';
		$iconlist[6]='<img src="/images/yesup_bar/20x20_icon_1.png">';
		
		$icon=new Zend_Form_Element_Select('icon');
		$icon->addMultiOptions($iconlist)
				->setAttrib('class','field text full')				
				->setAttrib('css','width:100px');				
				
/*		
		$country=new Zend_Form_Element_Select('country');
		$country->addMultiOptions($countrylist)
				->setAttrib('class','field text full')				
				->setAttrib('css','width:100px');				
				//->addDecorators(array( array( array("wrapper"=>'HtmlTag'), array('tag' => 'div','class' =>'right-column'))))
				//->setLabel('Country')
				//->getDecorator('Label')->setOptions(array('class'=>'desc'));

		$city=new Zend_Form_Element_Text('city');
		$city->setAttrib('class','field text full')
			->setAttrib('size',40)
			->addFilter('StringTrim')
			->addFilter('StripTags');
			//->addDecorators(array( array( array("wrapper"=>'HtmlTag'), array('tag' => 'div','class' =>'left-column'))))
			//->setLabel('City')
			//->getDecorator('Label')->setOptions(array('class'=>'desc'));

		$state=new Zend_Form_Element_Text('state');
		$state->setAttrib('class','field text full')
			->setAttrib('size',40)
			->addFilter('StringTrim')
			->addFilter('StripTags');
*/
						
		$max_display_time=new Zend_Form_Element_Text('max_display_times');
		$max_display_time->setAttrib('class','field text')
			->setAttrib('size',20)
			->addFilter('StringTrim')
			->addFilter('StripTags');

		$from_date=new Zend_Form_Element_Text('from_date');
		$from_date->setAttrib('class','field text datepicker')
			->setAttrib('size',40)
			->addFilter('StringTrim')
			->addFilter('StripTags');

		$end_date=new Zend_Form_Element_Text('end_date');
		$end_date->setAttrib('class','field text datepicker')
			->setAttrib('size',40)
			->addFilter('StringTrim')
			->addFilter('StripTags');

		$important=new Zend_Form_Element_Checkbox('important');
		$important->setAttrib('onclick','checkImportant();');
			
		$content=new Zend_Form_Element_Textarea('news_content');
		$content->setAttrib('rows',5)->setAttrib('cols',100);
		
        $news_id = $this->hiddenElement('news_id');
		
        $submit = $this->submit('submit', 'Submit');
        
        // create array of elements to add to the form
        $elements = array($dpt, $icon, $max_display_time, $from_date, $end_date, $important, $content, $news_id, $submit);

        $this->addElements($elements);

        // add error summary decorator (will list all validation errors at the
        // top of the form - all 'Error' decorators should be disabled since we
        // are not showing the errors next to the input item (just turning the
        // labels red)
        $this->addDecorator(new App_Form_Decorator_FormErrors(
                   array('placement'=>Zend_Form_Decorator_Abstract::PREPEND,
                    'message'=>'Summary')));

    }

    public function isValid($data)
    {
        
        return true;
    }

}
